﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Lib.Helper;
using MSIACCSL2.ViewModels;
using WcfService1.DTO;

namespace MSIACCSL2.Views.COA
{
    public partial class DetailSaldoPiutang: ChildWindow
    {
        public SaldoPiutangViewModel ViewModel
        {
            get { return (SaldoPiutangViewModel)this.DataContext; }
        }
        public DetailSaldoPiutang()
        {
            InitializeComponent();
            EventAggregator.RegisterMessage("SaveSaldoAwalPiutangFinished",(x)=>
                                                                              {
                                                                                  DialogResult = true;

                                                                              });
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
             ViewModel.SaveSaldoAwalPiutang();
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }

        private void btnAdd_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            var saldoAwalPiutang = new SaldoAwalPiutang();
            saldoAwalPiutang.Customers = ViewModel.SaldoAwalPiutangs.FirstOrDefault().Customers;
            ViewModel.SaldoAwalPiutangs.Add(saldoAwalPiutang);
            
        }

        private void btnDelete_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            ViewModel.SaldoAwalPiutangs.Remove((SaldoAwalPiutang) (sender as Button).DataContext);
        }
    }
}

